/* 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 3 of the License, or 
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License along 
 * with this program; if not, write to the Free Software Foundation, Inc., 
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#ifndef _WISHMASTER_BOARDPARSER_H
#define _WISHMASTER_BOARDPARSER_H

#include <QSet>
#include <QList>
#include <QString>
#include <QUrl>
#include <QtPlugin>
#include "extrainfo.h"
#include "components/threadid.h"
#include "components/postid.h"

namespace Wishmaster
{

	struct AttachmentInfo
	{
		QUrl thumbUrl;
		QUrl url;
	};

	struct ThreadInfo
	{
		ThreadId thread_id;
		QUrl leaderPicUrl;
		QString topic;
		unsigned long posts;
		unsigned long timestamp;
		QList<AttachmentInfo> opPostAttachments;
	};

	struct PostInfo
	{
		PostId post_id;
		QString name;
		QString topic;
		QString text;
		bool sage;
		unsigned long timestamp;
		QList<AttachmentInfo> attachments;
		QList<ExtraInfo> extras;
		QSet<PostId> replies;
	};
	
	class BoardParser
	{
	public:
		virtual ~BoardParser() {}

		virtual QList<ThreadInfo> getThreadList(const QString& chanName, const QString& boardId, const QByteArray& input) = 0;
		virtual QList<PostInfo> getPosts(const ThreadId& threadId, const QByteArray& input) = 0;
		virtual PostId getPostID(const QString& link, const ThreadId& threadId) = 0;

		virtual void setTimestampFormat(const QString& format) = 0;

		virtual QString id() = 0;
		virtual BoardParser* clone(const QString& boardname) = 0;

		virtual QList<PostId> findLinks(const ThreadId& threadId, const QString& posttext) = 0;
	};
}

Q_DECLARE_INTERFACE(Wishmaster::BoardParser, "com.googlecode.wishmaster.BoardParser/1.1")

#endif

